<?php
	namespace app\index\controller;
	use think\Controller;
	use think\Session;
	use think\Db;
	class Stu extends Controller{
		public function _initialize(){//初始化
			if(!Session::has('idnum')){//如果学生未登录
				return $this->success("请先登录！","Index/index");//返回登陆页面
			}
			$this->idnum=Session::get('idnum');
		}
		public function index(){
			$info=Db::table("tb_stu")->where('idnum',$this->idnum)->find();
			$this->assign('info',$info);
			return $this->fetch('index');
		}
		public function write(){

		}
		
		public function confirm(){//学生信息确认
			if(Db::table("tb_stu")->where('id', 1)->update(['confirm' => 1,'lasttime'=>date("Y-m-d H:i:s",time())])){
				/*echo "成功";*/
				// $this->success("确认操作成功","showParents");
				$this->redirect("showParents");
			}else{
				echo "失败";
			}
			/*$this->0assign('info',$info);
			return $this->fetch('second');*/
		}

		public function loginOut(){//退出
			Session::delete("idnum");
		}
	public function second(){
			if(Db::table("tb_stu")->where('id', 1)->update(['confirm' => 1,'lasttime'=>date("Y-m-d H:i:s",time())])){
				/*echo "成功";*/
			$this->redirect("showParents");
			}else{
				echo "失败";
			}
	    /*Db::table("tb_stu")->where('idnum',$this->idnum)->update(['infocheck'=>1]);
			$info=Db::table("tb_stu")->where('idnum',$this->idnum)->fetch();
			$this->assign('info',$info);
			return $this->fetch('second');*/

		}
		public function showParents(){//显示家长信息
			// echo "显示家长信息!";
			// 查询家长信息，显示
			$info=Db::table("tb_stu")->where('idnum',$this->idnum)->find();
			$this->assign("info",$info);
			return $this->fetch('parents');
			
		}
		public function parentsWrite(){//家长信息写入（修改）

		}
	}
	
?>